<template>
  <view class="content">
    <view class="">
      <uni-row :gutter="20">
        <uni-col :span="6"> 用户登录名 </uni-col>
        <uni-col :span="18">
          {{ loginName }}
        </uni-col>
      </uni-row>
      <uni-row :gutter="20">
        <uni-col :span="6"> 用户昵称 </uni-col>
        <uni-col :span="18">
          {{ userName }}
        </uni-col>
      </uni-row>
      <uni-row :gutter="20" class="row-action">
        <uni-col :span="24">
          <button type="primary" :loading="loading" @click="handleLogout()">退出登录</button>
        </uni-col>
      </uni-row>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      loading: false,
      loginName: '',
      userName: ''
    }
  },
  onLoad() {
    const user = uni.getStorageSync('user')
    console.log(user)
    if (user) {
      this.loginName = user.loginName
      this.userName = user.userName
    }
  },
  methods: {
    handleLogout() {
      uni.removeStorageSync('token')
      uni.removeStorageSync('user')
      uni.redirectTo({
        url: '/pages/login/index'
      })
    }
  }
}
</script>

<style>
.content {
  padding: 20upx;
}
.content .uni-row {
  margin: 20upx 0;
}
</style>
